import SwiftUI
import SPGlassKit

public struct GlassCardExample: GlassExample {
    public static let componentID = "glass-card"
    @State private var openCount = 0

    public init() {}

    public var body: some View {
        ScrollView {
            VStack(alignment: .leading, spacing: 16) {
                GlassCard("Monthly rent") {
                    Text("1,450 $").font(.title2)
                    Text("Sample listing · 4½ · Plateau").foregroundStyle(.secondary)
                }
                GlassCard {
                    Text("A long description wraps on several lines and stays readable because the card is opaque: dense text never sits on glass.")
                } header: {
                    Label("About this place", systemImage: "text.alignleft")
                } footer: {
                    Text("Fictitious data")
                }
                GlassCard {
                    // Any view: a photo, a map, a drawing. Give it a height.
                    Rectangle().fill(.tint.opacity(0.25)).frame(height: 120)
                        .overlay { Image(systemName: "building.2").font(.largeTitle).foregroundStyle(.tint) }
                        .accessibilityHidden(true)
                } content: {
                    Text("Two bedrooms · 74 m² · Balcony").foregroundStyle(.secondary)
                } header: {
                    Text("Loft on the canal")
                } footer: {
                    Label("Available 1 July", systemImage: "calendar")
                }
                GlassCard(style: .floating, action: { openCount += 1 }) {
                    Label("3 listings nearby", systemImage: "mappin.and.ellipse")
                    Text("Opened \(openCount) times").font(.caption)
                }
                .accessibilityHint("Opens the list")
            }
            .padding()
        }
    }
}

#Preview("GlassCard") { GlassCardExample().glassTheme(.ocean) }
